package exercises.Charpter9;

interface Cycle{
	void ride();
}

interface CycleFactory{
	Cycle getCycle ();
}

class Unicycle implements Cycle{

	@Override
	public void ride() {
		System.out.println("Unicycle ride");
	}
}

class UnicycleFactory implements CycleFactory{

	@Override
	public Cycle getCycle() {
		return new Unicycle();
	}
}

class Bicycle implements Cycle{
	@Override
	public void ride() {
		System.out.println("Bicycle ride");
	}
}

class BicycleFactory implements CycleFactory{

	@Override
	public Cycle getCycle() {
		return new Bicycle();
	}
}

class Tricycle implements Cycle{
	@Override
	public void ride() {
		System.out.println("Tricycle ride");
	}
}

class TricycleFactory implements CycleFactory{

	@Override
	public Cycle getCycle() {
		return new Tricycle();
	}
}

public class Eighteen {
	public static void ride(CycleFactory myFactory){
		Cycle myCycle = myFactory.getCycle();
		myCycle.ride();
	}
	
	public static void main(String[] args){
		ride(new UnicycleFactory());
		ride(new BicycleFactory());
		ride(new TricycleFactory());
	}
}
